let res = 0;
let str = 'aab'
function fn(str){
    for(i=0;i<str.length-1;i++){
        if(str[i]=='a'&&str[i+1]=="b") return false
    }
    return true
}
while(!fn(str)){
    str = str.replace("ab","bba")
    res++
}
console.log(res)
console.log(fn('ab'))
